<?php
/* $Id$ */

require_once "Container.class.php";


class ContainerProcessor extends Container {

	private	$registeredFilter_callbacks;

	function ContainerProcessor( $data_content ) {

		$this->Container( $data_content );

		$this->registerFilter( "plain", 	array (
								"revision"	=> "v1",
								"callback" 	=> array ($this, "plain_callback"),
								"parameter"	=> null
							)
		);

		$this->registerFilter( "encrypted", 	array (
								"revision"	=> "v1",
								"callback" 	=> array ($this, "encrypted_callback"),
								"parameter"	=> null
							)
		);


		$this->registerFilter( "base64", 	array (
								"revision"	=> "v1",
								"callback" 	=> array ($this, "base64_callback"),
								"parameter"	=> null
							)
		);
	}

	function registerFilter( $name, $callback_hash ) {
		$this->registeredFilter_callbacks[$name] = $callback_hash;
	}

	function getRegisteredFiler_callbacks() {
		return $this->registeredFilter_callbacks;
	}

	function setFilterParameter( $filterName, $parameter ) {
		$this->registeredFilter_callbacks[$filterName]["parameter"] = $parameter;
	}

	/**
         * Behandelt die raw Daten in $dataContent entsprechend ihrer Bestimmung,
	 * erlaubt ueber das Array $container_types_array ein Kombinieren
         * der verschiedenen Filter und liefert den behandelten Datenblock zurueck
         **
         * @return gefilterter Datenblock
	 */

	function processData ( $container_types_hasharray ) {

		$processedDataContent = $this->getRawContent();

		foreach( $container_types_hasharray as $value ) { 

			$processedDataContent = call_user_func( 
				$this->registeredFilter_callbacks[$value]["callback"], 
				$processedDataContent,
				$this->registeredFilter_callbacks[$value]["parameter"] 
				 
			); 
		}

		return $processedDataContent;
	}

	function plain_callback( $dataContent,	$dummyParameter ) {
		return $dataContent;
	}

	function encrypted_callback( $dataContent, $passPhrase ) {

		/* TODO: Verschluessle $dataContent */
	
		return $dataContent;
	}

	function base64_callback( $dataContent, $dummyParameter ) {

		/* TODO: Base64 codieren */

		return $dataContent;
	}



}


?>